﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoodMan.Infrastructure.Entities.Repository;

namespace GoodMan.Infrastructure.Entities.Entity
{
    public class CostRecord : IAccessible<T_CostRecord, CostRecord>, ILogicEntity<T_CostRecord, CostRecord>
    {
        public int Id { get; set; }

        public string UserName { get; set; }
        /// <summary>
        /// 消费金额
        /// </summary>
        public decimal Cost { get; set; }

        public string ProductName { get; set; }

        public string Remark { get; set; }
        /// <summary>
        /// 消费时间
        /// </summary>
        public DateTime CostDate { get; set; }
        /// <summary>
        /// 消费后余额
        /// </summary>
        public decimal Balance { get; set; }

        protected override void Covariant(T_CostRecord model)
        {
            if (model != null)
            {
                this.Balance = model.Balance;
                this.Cost = model.Cost;
                this.CostDate = model.CostDate;
                this.Id = model.Id;
                this.ProductName = model.ProductName;
                this.Remark = model.Remark;
                this.UserName = model.UserName;
            }
        }

        protected override T_CostRecord Inverter(CostRecord model)
        {
            if (model != null)
            {
                return new T_CostRecord()
                {
                    Balance = model.Balance,
                    Cost = model.Cost,
                    CostDate = model.CostDate,
                    Id = model.Id,
                    ProductName = model.ProductName,
                    Remark = model.Remark,
                    UserName = model.UserName
                };
            }
            return null;
        }

        public CostRecord Set(T_CostRecord dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
